NS2 programs:
- NS2 programs are developed to simulate wireless, mobile network projects .NS2 programs are discrete event programs . Network Simulator NS2 maintains a event queue and executes the next event in the queue. The simulator stops when all events completed.
-
Languages in NS2:
-
1.C++ -It is the core of the NS2 programs
2.OTCL - Used for periodic triggering and to manipulate existing c++ objects.
-
To write a simple NS2 program:
- Let us consider a simple scenario for implementing a wireless network in scenario. A boundary is set between the nodes say for example we are creating two nodes node0 and node1 , boundary is set as 500m X 500m. A TCL connection is made between these nodes, when the simulation starts the node move away from the boundary for certain simulation period and comes near for next half simulation period . Packets are transferred between these nodes when these nodes are within the boundary range and packets are lost when it move away from the network boundary.
1.To start a NS2 program first define options,
Once the TCL script is started we have to set the values like what type of channel,MAC type , network type, total number of mobile nodes.
2.Create instance of Network simulator
It creates new object for the simulator and the value is stored in the variable ns. Once this object is created the scheduler is created and packets are initialized
3.Create trace file with the following
The trace file is created and all the traces that are created during the simulation time is recorded in the trace file.
4. Create topology
It is used to create the area where the simulation run
5. To set up boundary
Once the area is created , the boundary of the area is set here 500 500 represents the area of the topography created
6.Node configuration is done
Once after the node is created , we have to configure the node with its mactype, channel type, energy model, etc.
7. For Node movement
The node movement is specified as at what time the node has to move and where the node has to move.
8. To start the simulation
$ns_ run
In order to run the simulation we need to give the $ns_ run.
Sink node replacement algorithm in Omnet++ projects:
We help and support all U.G/P.G scholars to simulate the networks using ns2 programs and guide them in all way.